package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.RightsMapper;
import com.jt.pojo.Rights;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Service
public class RightsServiceImpl implements RightsService{
    @Autowired
    private RightsMapper rightsMapper;

    @Override
    public List<Rights> findRightsList() {
        QueryWrapper<Rights> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("parent_Id", 0);
        List<Rights> oneList= rightsMapper.selectList(queryWrapper);
        for(Rights oneRights: oneList){
            QueryWrapper<Rights> queryWrapper2=new QueryWrapper<>();
            queryWrapper2.eq("parent_Id",oneRights.getId());
            List<Rights> twoList=rightsMapper.selectList(queryWrapper2);
            oneRights.setChildren(twoList);
        }

        return oneList;
    }
}
